package com.webbei.myCustom.dao.impl;

import java.util.List;
import org.apache.ibatis.session.SqlSession;
import com.webbei.myCustom.dao.myCustomDao;
import com.webbei.pojo.Customer;
import com.webbei.pojo.Customs;
import com.webbei.pojo.Orders;

public class myCustomDaoImpl implements myCustomDao{
	private SqlSession session;
	public SqlSession getSession() {
		return session;
	}
	public void setSession(SqlSession session) {
		this.session = session;
	}
	public List<Customs> getCustomsByUserName(String userName) {
		return session.selectList("cust.getCustomByName", userName);
	}
	public Customer getCustomerByUserName(String userName) {
		return (Customer) (session.selectList("customer.getCustomerByUserName", userName).get(0));
	}
	public List<Orders> getOrderByUserName(String userName) {
		return session.selectList("orders.getOrderByUserName",userName);
	}
	public int deleCustom(Integer customId) {
		return session.delete("cust.deleCustom",customId);
	}
	public int saveCustom(Customs c) {
		System.out.println("c.:"+c.getCustomName());
		return session.insert("cust.createCustom",c);
	}
	public Double getPriceByBgPic(String backPicUrl) {
		Double d=(Double) session.selectList("cust.getPriceByBgPic", backPicUrl).get(0);
		return d;
	}
	public Customs getCustomById(Integer id) {
		return (Customs) session.selectOne("cust.getCustomsById",id);
	}

}
